<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>添加下级代理</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/style.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/jquery.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/bootstrap.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/ckform.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/common.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/layerui/layer.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/layerui/layer.ext.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 1;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<table class="table table-bordered table-hover definewidth m10">
    
     <tr>
        <td style="text-align: right;" class="tableleft">字典类型</td>
        <td><input type="text" name="dictType" id="dictType" ${dict.dictType!=null?'disabled':''} value="${dict.dictType}"/></td>
    </tr>
    <tr>
        <td width="30%" style="text-align: right;"  class="tableleft">字典名称</td>
        <td>
        <input type="hidden" name="id" id="id" value="${dict.id}"/>
        <input type="text" name="dictName" id="dictName" value="${dict.dictName}"/></td>
    </tr>
    <tr>
        <td style="text-align: right;" class="tableleft">字典值</td>
        <td><input type="text" name="dictValue" id="dictValue" value="${dict.dictValue}"/></td>
    </tr>
    
    <tr>
        <td style="text-align: right;" class="tableleft">是否可删除</td>
        <td>
        <select name="isDel" id="isDel" ${dict.id!=null?'disabled':''}>
	        <option value="0" ${dict.isDel==null?'':dict.isDel==0?'selected':''}>可删除</option>
	        <option value="1" ${dict.isDel==null?'':dict.isDel==1?'selected':''} >不可删除</option>
        </select>
        </td>
    </tr>
    <tr>
        <td style="text-align: right;" class="tableleft">排序</td>
        <td>
            <input type="text" name="orderSort" id="orderSort" value="${dict.orderSort}" /> 
        </td>
    </tr>
    <tr>
        <td style="text-align: right;" class="tableleft">说明</td>
        <td>
        <textarea rows="2" cols="30" name="remark" id="remark">${dict.remark}</textarea>
        </td>
    </tr>
    
    <tr>
        <td class="tableleft"></td>
        <td>
            <button type="button" id="usersave" class="btn btn-primary" type="button">添加</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">关闭</button>
        </td>
    </tr>
</table>
</body>

<script>
    $(function () {       
		$('#backid').click(function(){
			var system ={}; 
	        var p = navigator.platform;      
	        system.win = p.indexOf("Win") == 0; 
	        system.mac = p.indexOf("Mac") == 0; 
	        system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);    
	        if(system.win||system.mac||system.xll){
	    		//如果是电脑跳转到弹出框 
	        	parent.layer.close(parent.lindex);
	        }else{  
	    		//如果是手机,跳转到页签
	    		window.location.href="${pageContext.request.contextPath}/admin/user_next_info.html";
	        }
		 });
	
		
		$('#usersave').click(function(){
			$('#usersave').attr('disabled',"true"); //添加disabled属性 
			var id = $("#id").val();
			var dictName = $("#dictName").val();
			var dictValue = $("#dictValue").val();
			var dictType = $("#dictType").val();
			var orderSort = $("#orderSort").val();
			var remark = $("#remark").val();
			var isDel = $('#isDel option:selected').val();
			if(dictType==""){
				layer.alert("请填写用户名");
				return;
			}
			if(dictName==""){
				layer.alert("请填写字典名称");
				return;
			}
			if(dictValue==""){
				layer.alert("请填写字典值");
				return;
			}
			$.post("${pageContext.request.contextPath}/admin/dict_edit_save.html",
		            {"id":id,"dictName":dictName,"dictValue":dictValue
				,"dictType":dictType ,"orderSort":orderSort,"remark":remark,"isDel":isDel},
		       function(data){
		            	var json = eval("("+data+")");
		            	$('#usersave').removeAttr("disabled");  //移除disabled属性 
						if(json.statusCode =='200'){
							layer.msg(json.message, {icon: 1});
							setTimeout("closewind()",2000);
						}else{
    						layer.msg(json.message, {shift: 6});
    					}
		      });
			
			
			
		 });
    });
    function closewind(){
    	parent.layer.close(parent.lindex);
    }
</script>
</html>